<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="s" uri="/struts-tags" %>
<%--<script src="<%=request.getContextPath()%>/js/main/jquery-latest.js" type="text/javascript" language="javascript"></script>--%>

<script type="text/javascript">
$(document).ready(function(){
//       alert($(window).outerHeight(true));
   var ajaxLoading = false;
    $("#waiting").css("display","none");
      $("#start").click(function(){
          if(!ajaxLoading){
                     ajaxLoading=true;
                      $("#waiting").show();
                    $.ajax({
                            url: "startServer.action",
                            cache:false,
                            type:"post",
                            success:function(result) {
                                ajaxLoading = false;
                               if(result == "success"){
                                   alert("server started");
                                   $("#server").find("div").css("backgroundImage", "url(images/server/server1.png)");
                               } else if(result == "error"){
                                   alert("error occurred");
                               } else if (result == "input"){
                                  alert("Server has been already started!");
                               }else if(result == "does_not_started"){
                                  alert("Server has not been started!");
                               }
                                $("#waiting").hide();
                            }
                     });
                }
          }) ;
      $("#stop").click(function(){
            if(!ajaxLoading){
                  ajaxLoading=true;
                 $("#waiting").show();
                 $.ajax({
                           url: "stopServer.action",
                           cache:false,
                           type:"post",
                           success:function(result) {
                              if(result == "success"){
                                   alert("server stopped");
                                   $("#server").find("div").css("backgroundImage", "url(images/server/server2.png)");
                               }else  if(result == "error"){
                                   alert("error occurred");
                              }else  if(result == "input"){
                                   alert("Server has been already stopped!");
                              }else if(result == "does_not_stopped"){
                                  alert("Server has not been stopped!");
                               }
                                 $("#waiting").hide();
                            }
                 });
           ajaxLoading=false;
          }
      }) ;
})
</script>
<style type="text/css">

    #grayBox {
        z-index: 100;
    }

    #hello {
        margin-top:80px;
        margin-left: 390px;
        font-size:20px;
        font-family:Arial;
        font-style:italic;
        margin-bottom:10px;
    }
</style>
   <div id="grayBox"></div>
   <div id="waiting"></div>
<div id="hello">
    WELCOME    <s:property value="#session.user.username"/>  !!!
</div>
<div style="width:130px; margin: 0 auto;padding-top:0px;height:160px; ">
    <img src="<%=request.getContextPath()%>/images/admin/server.png" alt="acs server"/>
    <div style="width:150px; margin: 5px auto;padding-left: 10px;">
         <button id="start">start</button>
         <button id="stop">stop</button>
    </div>
</div>